package com.liang.map;

import java.util.HashMap;
import java.util.Map;

public class HashMapDemo {
    public static void main(String[] args) {
        //创建hashmap
        Map<String, String> map = new HashMap<>();

        //储存元素
        method1(map);

        //删除元素
//        method2(map);

        //清除元素
//        method3(map);

        //是否包含某个键
//        method4(map);

        //是否包含某个值
//        method5(map);

        //是否为空
//        method6(map);

        //map中ertry对象的长度
        int size = map.size();
        System.out.println(size);

        System.out.println(map);
    }

    public static void method6(Map<String, String> map) {
        boolean result = map.isEmpty();
        map.clear();
        boolean result1 = map.isEmpty();
        System.out.println(result+"-----"+result1);
    }

    public static void method5(Map<String, String> map) {
        boolean result = map.containsValue("小白");
        boolean result1 = map.containsValue("小黑");
        System.out.println(result+"-----"+result1);
    }

    public static void method4(Map<String, String> map) {
        boolean result = map.containsKey("itheima01");
        boolean result1 = map.containsKey("itheima10");
        System.out.println(result+"-----"+result1);
    }

    public static void method3(Map<String, String> map) {
        map.clear();
    }

    public static void method1(Map<String, String> map) {
        map.put("itheima01", "小美");
        map.put("itheima02", "小明");
        map.put("itheima03", "小红");
        map.put("itheima04", "小白");
        map.put("itheima05", "小智");
        map.put("itheima06", "小胖");
    }

    public static void method2(Map<String, String> map) {
        map.remove("itheima01");
    }
}
